package com.yc.hotel.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yc.hotel.util.FindByPageParamsUtil;
import com.yc.hotel.dto.RoomInfoDTO;
import com.yc.hotel.entity.RoomInfo;
import com.yc.hotel.mapper.IRoomInfoMapper;
import com.yc.hotel.service.IRoomInfoService;
import com.yc.hotel.util.StringUtil;

@Service
public class RoomInfoServiceImpl implements IRoomInfoService{
	
	@Autowired
	private IRoomInfoMapper roomInfoMapper;
	
	@Override
	public int add(RoomInfo rf) {
		if(!StringUtil.checkNull(rf)) {
			return roomInfoMapper.add(rf);
		}
		return -1;
	}

	@Override
	public int update(Map<String, Object> map) {
		if(!StringUtil.checkNull(map)) {
			return roomInfoMapper.update(map);
		}
		return -1;
	}

	@Override
	public List<RoomInfo> findByPage(Map<String, Object> map) {
			return roomInfoMapper.findByPage(FindByPageParamsUtil.findByPageParam(map));
	}

	@Override
	public int total(Map<String, Object> map) {
		if(!StringUtil.checkNull(map)) {
			return roomInfoMapper.total(map);
		}
		return -1;
	}

	@Override
	public int updateStatus(Map<String, Object> map) {
		if(!StringUtil.checkNull(map)) {
			return roomInfoMapper.updateStatus(map);
		}
		return -1;
	}

	@Override
	public RoomInfo findByRno(String rno) {
		if(StringUtil.checkNull(rno)) {
			return null;
		}
		return roomInfoMapper.findByRno(rno);
	}

	@Override
	public List<RoomInfo> finds(Map<String, Object> map) {
		if(StringUtil.checkNull(map)) {
			return null;
		}
		return roomInfoMapper.finds(map);
	}

	@Override
	public List<RoomInfo> findIndex(Map<String, Object> map) {
		if(StringUtil.checkNull(map.get("tno"))){
			return null;
		}
		return roomInfoMapper.findIndex(map);
	}

	@Override
	public RoomInfoDTO findByRno(int rno) {
		// TODO Auto-generated method stub
		return roomInfoMapper.findByRnoF(rno);
	}

	@Override
	public int endSale(RoomInfoDTO room) {
		// TODO Auto-generated method stub
		return roomInfoMapper.endSale(room);
	}

	@Override
	public List<RoomInfoDTO> findsF(Map<String, Object> map) {
		if(StringUtil.checkNull(map)) {
			return null;
		}
		return roomInfoMapper.findsF(map);
	}

	@Override
	public int addF(RoomInfoDTO room) {
		// TODO Auto-generated method stub
		return roomInfoMapper.addF(room);
	}

}
